{% extends 'index.html' %}
{% load custom_tag %}


{% block extra_head_resources %}


{% endblock %}


{% block breadcrumb %}
    <ol class="breadcrumb">
        <li><a href="{% url 'table_index' %}">配置中心</a></li>
        <li><a href="{% url 'table_list' model_db_table %}">{{ model_name }}</a></li>
        <li class="active"> 修改 {{ model_name }}</li>
    </ol>
 {% endblock %}

{% block page-content %}


{% include 'king_admin/filter_search_box.html' %}


<div class="panel">
    <div class="panel-heading">
        <h3 class="panel-title">Change {{ model_name }}
        <button class="btn btn-sm btn-info btn-labeled fa fa-mail-reply pull-right">
            <a href="{% url 'table_list' model_db_table %}">返回 {{ table_obj.model_verbose_name }}</a>
        </button>
        </h3>
    </div>

    <form method="post" onsubmit="return CheckSelectedOptions()" class=" form-horizontal form-padding">{% csrf_token %}
        <div class="panel-body">
            <span style="color: red">{{ form_obj.errors  }}</span>

            {% for field in form_obj %}
                <div class="form-group">
                    {%if field.field.required%}
                        <label class="col-md-2 control-label">
                            <b>{{field.label}}</b>
                        </label>
                    {% else %}
                        <label class="col-md-2 control-label">
                           {{field.label}}
                        </label>
                    {% endif %}

                    <div class="col-md-9">
                        {% if field.name not in admin_class.filter_horizontal %}
                            {{ field }} {% add_fk_search_btn form_obj field %}
                            {% add_onclick_link form_obj field %}
{#                            {% decorate_date_field form_obj field %}#}
                            {% if field.errors %}
                                <span style="color: red">{{ field.errors }}</span>
                            {% endif %}
                        {% else %}
                            {% include 'king_admin/filter_horizontal_multi_select.html' %}
                        {% endif %}
                    </div>
                </div>
            {% endfor %}
        </div> <!--end panel-body-->
        <div class="panel-footer">
            <div class="row">
                {% if  not admin_class.readable_table3  %}
                <div class="col-sm-2 ">
                    <a href="{% url 'table_del' model_db_table form_obj.instance.id %}" class="btn btn-danger " type="reset">Delete</a>
                </div>

                <div class="col-sm-4 ">
                    <button class="btn btn-info pull-right "  type="submit">Save</button>
                </div>
                {% endif %}
            </div>
        </div>
    </form>

</div>
<script src="/static/js/king_admin/filter_horizontal.js"></script>
{% endblock %}